import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:yuan_hang_app/bean/user.dart';
import 'package:yuan_hang_app/res/w_colors.dart';
import 'package:yuan_hang_app/res/w_constant.dart';
import 'package:yuan_hang_app/utils/string_utils.dart';
import 'package:yuan_hang_app/widget/water_mark.dart';

import 'custom_appbar.dart';

class FullBasePage extends StatelessWidget {
  final Key? mKey;
  final String? title;
  final Color? titleColor;
  final Color titleBackgroundColor;
  final AssetImage? backGroundImage;
  final Widget? leftWidget;
  final Widget? centerWidget;
  final Widget? rightWidget;
  final double marginTop;
  final Widget child;
  final bool statusStyleDark;
  final Color backgroundColor;
  final Function? leftCallBack;
  final bool resizeToBottomInset;
  final bool hideDivide;
  final bool hideNavi;
  final double? height;
  final Widget? bottomNavigationBar;

  FullBasePage({
    super.key,
    this.title,
    this.mKey,
    this.leftWidget,
    this.leftCallBack,
    this.centerWidget,
    this.rightWidget,
    this.backgroundColor = WColors.CF8F9FA,
    this.titleColor,
    this.titleBackgroundColor = Colors.white,
    this.backGroundImage,
    this.marginTop = 0,
    this.statusStyleDark = true,
    this.resizeToBottomInset = false,
    this.hideDivide = true,
    this.hideNavi = false,
    this.height,
    this.bottomNavigationBar,
    required this.child,
  });

  BuildContext? buildContext;

  @override
  Widget build(BuildContext context) {
    buildContext = context;
    User userInfo  =  WConstant().userInfo ;
    return Scaffold(
      key: mKey,
      backgroundColor: backgroundColor,
      resizeToAvoidBottomInset: resizeToBottomInset,
      bottomNavigationBar: bottomNavigationBar,
      body: AnnotatedRegion<SystemUiOverlayStyle>(
        value: statusStyleDark
            ? SystemUiOverlayStyle.dark
            : SystemUiOverlayStyle.light,
        child: Column(
          children: <Widget>[
            if (!hideNavi)
              CustomAppBar(
                contentTitle: title ?? "",
                contentTitleColor: titleColor,
                backColor: titleBackgroundColor,
                backGroundImage: backGroundImage,
                leftWidget: leftWidget,
                centerWidget: centerWidget,
                rightWidget: rightWidget,
                leftCallBack: leftCallBack,
                hideDivide: hideDivide,
                height: height,
                marginTop: marginTop,
              ),
            Expanded(
              child: Watermark(
                text:
                    "${StringUtils.safeGetValue(userInfo.employeeName)} ${StringUtils.safeGetValue(userInfo.roleName)}",
                child: child,
              ),
            )
          ],
        ),
      ),
    );
  }
}
